﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Scheduling.Models;
using Scheduling.Models.Interfaces;
using Scheduling.Models.Repos.InMemory;
using Scheduling.Models.Repos.Database;

namespace Scheduling
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801




    public class MvcApplication : System.Web.HttpApplication
    {

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute("HomeSearch", "Home/Search/{query}", new { controller = "Home", action = "Search", query = UrlParameter.Optional });

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );


        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);

            IoC.CreateEmptyContainer();
            IoC.RegisterType<IUserLoader, DatabaseUserLoader>();
            IoC.RegisterType<IRoomLoader, DatabaseRoomLoader>();
            IoC.RegisterType<IRoomPropertyLoader, DatabaseRoomPropertyLoader>();
            IoC.RegisterType<ICourseLoader, DatabaseCourseLoader>();
            IoC.RegisterType<IBookingLoader, DatabaseBookingLoader>();
            IoC.RegisterType<ICourseInstanceLoader, DatabaseCourseInstanceLoader>();
            IoC.RegisterType<IUserGroupLoader, DatabaseUserGroupLoader>();
            IoC.RegisterType<IDepartmentLoader, DatabaseDepartmentLoader>();
            IoC.RegisterType<IBookingRequestLoader, DatabaseBookingRequestLoader>();
        }
    }
}